<template>
	<view>
		<view class="box">
			<view class="info" @click="toCourseDetails()">
				<image :src="orderinfo.img.split(',')[0]" class="info_left" v-if="orderinfo.img"></image>
				<view class="info_right">
					<view class="title_box">
						<view class="title">{{ orderinfo.activity_name }}</view>
						<!-- pay_status 0未支付 1已支付2部分退款3全部退款 -->
						<view class="status">{{orderinfo.verifiy_status==0?'未核销':'已核销' }}</view>
					</view>
					<view class="time_box">
						<!-- <view class="tag">报名截止时间</view> -->
						<view class="time">活动时间：{{ dateFormat(orderinfo.start_time) }}</view>
						<!-- <view class="class_hour">共{{item.class_num}}课节</view> -->
					</view>
					<view class="time_box">
						<!-- <view class="tag">报名截止时间</view> -->
						<!-- <view class="time">活动地址：滨江1号 14栋 2单元 302</view> -->
						<!-- <view class="class_hour">共{{item.class_num}}课节</view> -->
					</view>
					<view class="teacher" style="color: #222">
						<view>￥{{ orderinfo.pay_money }}</view>
					</view>
				</view>
			</view>
			<!-- is_start 0未开始 1已开始 -->
			<!-- pay_status 0未支付 1已支付2部分退款3全部退款 -->
			<!-- <view class="btns" v-if="orderinfo.pay_money > 0 && orderinfo.activity_status == 0 && (orderinfo.pay_status == 1 || orderinfo.pay_status == 2)">
				<view class="btn_box">
				</view>
			</view> -->
			<!-- <view class="btns">
				<view v-if="orderinfo.activity_status == 0" class="btn1" @click="toApplyRefund">申请取消</view>
			</view> -->
			<!-- <view class="btns" > -->
			<!-- <view class="btn_box">
					<view class="btn1" @click="toApplyRefund">申请取消</view>
					<view class="btn2" :style="{'opacity':orderinfo.is_can_hx==0?0.5:''}" @click="openHxm(item)">核销二维码</view>
				</view> -->
			<!-- 	<view class="btn3"  @click="openHxm">核销二维码</view>
			</view> -->
		</view>
		<!-- <view class="infobox">
			<view class="title">报名信息</view>
			<view class="infotit">
				<view class="name">订单号</view>
				<view>500017086791<text style="color: #FE768A;">复制</text></view>
			</view>
			<view class="infotit">
				<view class="name">活动人数</view>
				<view>30人</view>
			</view>
			<view class="infotit">
				<view class="name">课本费</view>
				<view>3688积分+￥10</view>
			</view>
			<view class="infotit">
				<view class="name">支付方式</view>
				<view>在线支付</view>
			</view>
			<view class="infotit">
				<view class="name">报名时间</view>
				<view>2023.06.16  14:00</view>
			</view>
		</view> -->
		<!-- activity_status 3已完成 0'未开始',1'进程中',2'已结束' -->
		<!-- 核销状态0未核销 1己核销· -->
		<view class="listbox">
			<view class="title">
				报名信息
			</view>
			<view class="code"
				v-if="orderinfo.activity_code&&orderinfo.activity_status !=2&& orderinfo.pay_status == 1">
				<image style="width: 500rpx;height: 500rpx;margin: 0 auto;" :src="baseUrl + orderinfo.activity_code">
				</image>
			</view>
			<view class="code" v-if="orderinfo.activity_status == 2 && orderinfo.pay_status == 1">
				<image style="width: 500rpx;height: 500rpx;margin: 0 auto;" src="../../static/un.png"></image>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import {
		baseUrl
	} from "../../setting"

	export default {
		data() {
			return {
				baseUrl,
				orderinfo: {},
				openindex: 5,
				id: "",
				pay_status: ["未支付", "已支付", "部分退款", "全部退款"], //pay_status 0未支付 1已支付2部分退款3全部退款
			}
		},
		onLoad(option) {
			this.id = option.id
			this.getinfo()
		},
		onShow() {
			this.getinfo()
		},
		methods: {
			getinfo() {
				this.$http({
					url: "/api/api/activityUserDetail",
					data: {
						activity_user_id: this.id,
					},
				}).then((res) => {
					this.orderinfo = res.data
				})
			},
			refound() {
				// this.getinfo(this.id)
				this.toApplyRefund()
				// if(fitem.family_status==1){
				// 	this.toApplyRefund(fitem)
				// }else{
				// 	uni.showToast({
				// 		title:'改二维码已核销',
				// 		icon:'none'
				// 	})
				// }
			},
			toApplyRefund() {
				uni.navigateTo({
					url: "/pages/applyRefund/applyRefund?id=" + this.id + "&type=" + 1, //1活动2课程3商城
				})
			},
			more() {
				if (this.openindex == 9999) {
					//
					this.openindex = 5
				} else {
					this.openindex = 9999
				}
				if (this.list.length <= 5) {
					uni.showToast({
						title: "已展示全部",
						icon: "none",
					})
				}
			},
			dateFormat: function(value) {
				var date = new Date(value * 1000) //时间戳为10位需*1000，时间戳为13位的话不需乘1000
				var year = date.getFullYear()
				var month = ("0" + (date.getMonth() + 1)).slice(-2)
				var sdate = ("0" + date.getDate()).slice(-2)
				var hour = ("0" + date.getHours()).slice(-2)
				var minute = ("0" + date.getMinutes()).slice(-2)
				var second = ("0" + date.getSeconds()).slice(-2)
				// 拼接
				var result = year + "年" + month + "月" + sdate + "日 " + hour + ":" + minute //+ ":" + second;
				// 返回
				return result
			},
			openHxm(item) {
				this.$http({
					url: "/api/Api/familyActivityScanCode",
					data: {
						activity_id: this.orderinfo.activity_id,
						id: item.id,
					},
				}).then((res) => {
					uni.showToast({
						title: res.msg,
						icon: "none",
					})
					this.getinfo()
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 750rpx;
		background: #ffffff;
		border-radius: 10rpx;
		padding: 36rpx 30rpx 0 30rpx;
		box-sizing: border-box;
		margin-bottom: 24rpx;

		.info {
			display: flex;
			justify-content: space-between;
			gap: 0 26rpx;
			padding-bottom: 30rpx;

			.info_left {
				width: 160rpx;
				height: 160rpx;
				background: #ffffff;
				border-radius: 6rpx;
				flex-shrink: 0;
			}

			.info_right {
				width: 100%;
				display: flex;
				flex-direction: column;

				.title_box {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-bottom: 30rpx;

					.title {
						width: 400rpx;
						font-size: 36rpx;
						font-family: Source Han Sans CN-Medium, Source Han Sans CN;
						font-weight: 500;
						color: #222222;
						line-height: 1em;
						-webkit-line-clamp: 1;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						overflow: hidden;
						text-overflow: ellipsis;
					}

					.status {
						font-size: 28rpx;
						font-family: Source Han Sans CN-Medium, Source Han Sans CN;
						font-weight: 500;
						color: #ff8a9b;
					}
				}

				.time_box {
					display: flex;
					align-items: center;
					margin-bottom: 20rpx;
					// justify-content: space-between;

					.tag {
						padding: 6rpx 6rpx 4rpx 6rpx;
						background: linear-gradient(180deg, #fcbb8c 0%, #ff8158 100%);
						font-size: 28rpx;
						font-family: Source Han Sans CN-Medium, Source Han Sans CN;
						font-weight: 500;
						color: #ffffff;
						line-height: 1em;
						border-radius: 4rpx 8rpx 8rpx 8rpx;
						margin-right: 18rpx;
					}

					.time {
						font-size: 28rpx;
						font-family: Source Han Sans CN-Regular, Source Han Sans CN;
						font-weight: 400;
						color: #555555;
						line-height: 1em;
						// margin-right: 20rpx;
					}

					.class_hour {
						font-size: 28rpx;
						font-family: Source Han Sans CN-Regular, Source Han Sans CN;
						font-weight: 400;
						color: #555555;
						line-height: 1em;
					}
				}

				.teacher,
				.student {
					font-size: 28rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #555555;
					line-height: 1em;
					display: flex;
					align-items: center;

					.studentitem {
						display: flex;
						width: 400rpx;

						>view {
							-webkit-line-clamp: 1;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							overflow: hidden;
							text-overflow: ellipsis;
						}
					}

					>view {
						-webkit-line-clamp: 1;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}

				.teacher {
					margin-bottom: 20rpx;
				}
			}
		}

		.btns {
			width: 690rpx;
			height: 108rpx;
			border-top: 2rpx solid #ececec;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.btn_box {
				width: 100%;
				height: 100%;
				display: flex;
				justify-content: space-between;
				align-items: center;
			}

			.btn1 {
				width: 320rpx;
				height: 68rpx;
				border-radius: 36rpx;
				border: 2rpx solid #888888;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #222222;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.btn2 {
				width: 320rpx;
				height: 68rpx;
				background: #ff8a9b;
				border-radius: 36rpx;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #ffffff;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.btn3 {
				width: 690rpx;
				height: 68rpx;
				border-radius: 36rpx;
				background: #ff8a9b;
				// border: 2rpx solid #888888;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #fff;
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}
	}

	.infobox {
		width: 690rpx;
		background: #ffffff;
		border-radius: 20rpx;
		opacity: 1;
		padding: 0 30rpx;

		.title {
			height: 120rpx;
			line-height: 120rpx;
			font-size: 40rpx;
			font-family: SourceHanSansCN-Medium-, SourceHanSansCN-Medium;
			font-weight: normal;
			color: #ff6178;
		}

		.code {
			width: 600rpx;
			margin: 0 auto;
			text-align: center;

			image {
				width: 500rpx;
				height: 500rpx;
				margin: 0 auto;
			}
		}

		.infotit {
			height: 100rpx;
			display: flex;
			font-size: 32rpx;
			font-family: Source Han Sans CN-Medium, Source Han Sans CN;
			font-weight: 500;
			color: #222222;
			justify-content: space-between;

			.name {
				font-size: 32rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #666666;
			}
		}
	}

	.listbox {
		width: 690rpx;
		background: #ffffff;
		border-radius: 20rpx;
		opacity: 1;
		padding: 0 30rpx;

		.title {
			height: 120rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 40rpx;
			font-family: SourceHanSansCN-Medium-, SourceHanSansCN-Medium;
			font-weight: normal;
			color: #ff6178;

			>view {
				display: flex;
				align-items: center;
				font-size: 30rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #222222;

				image {
					width: 18rpx;
					height: 14rpx;
					margin-left: 14rpx;
				}
			}
		}

		.code {
			width: 600rpx;
			margin: 0 auto;
			text-align: center;
		
			image {
				width: 500rpx;
				height: 500rpx;
				margin: 0 auto;
			}
		}
	}
</style>